
<template>
  <el-select v-model="workshopKeyId" size="small" style="width:100%" filterable clearable @change="returnChange" placeholder="请选择生产线" >
    <el-option
      v-for="item in workShopList"
      :key="item.workshopId"
      :label="item.workshopName"
      :value="item.workshopId">
    </el-option>
  </el-select>
</template>

<script>
import { listWorkshop } from "@/api/erp/system/workshop";

export default {
  data() {
    return {
      workShopList : [],
      workshopKeyId : '',
    };
  },
  model:{
    prop:'workshopId',
    event: 'change'
  },
  watch:{
    workshopId : function(newValue, oldValue){
      this.workshopKeyId = newValue;
    }
  },
  props: {
    //用于绑定和初始选中的仓库ID
    workshopId: 0,
    // 生产线属性 : 酸洗、轧硬、镀锌、彩涂，其他 关联：sys_dict_data
    workshopProperty : 0,
    // 公司名称，属于哪个公司，关联：sys_dict_data
    dictCode : 0,
  },
  methods: {
    returnChange(){
      this.$emit('change', this.workshopKeyId);
    },
  },
  created() {
      listWorkshop({workshopProperty:this.workshopProperty, dictCode : this.dictCode}).then((response) => {
          this.workShopList = response.rows;
      });
  },
};
</script>
